<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActiveSupport::CoreExtensions::Time::Calculations</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActiveSupport::CoreExtensions::Time::Calculations</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../../files/vendor/rails/activesupport/lib/active_support/core_ext/time/calculations_rb.html">
                vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Enables the use of time calculations within Time itself
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000576">advance</a>&nbsp;&nbsp;
      <a href="#M000577">ago</a>&nbsp;&nbsp;
      <a href="#M000595">at_beginning_of_day</a>&nbsp;&nbsp;
      <a href="#M000598">at_beginning_of_month</a>&nbsp;&nbsp;
      <a href="#M000602">at_beginning_of_quarter</a>&nbsp;&nbsp;
      <a href="#M000590">at_beginning_of_week</a>&nbsp;&nbsp;
      <a href="#M000604">at_beginning_of_year</a>&nbsp;&nbsp;
      <a href="#M000600">at_end_of_month</a>&nbsp;&nbsp;
      <a href="#M000594">at_midnight</a>&nbsp;&nbsp;
      <a href="#M000592">beginning_of_day</a>&nbsp;&nbsp;
      <a href="#M000597">beginning_of_month</a>&nbsp;&nbsp;
      <a href="#M000601">beginning_of_quarter</a>&nbsp;&nbsp;
      <a href="#M000588">beginning_of_week</a>&nbsp;&nbsp;
      <a href="#M000603">beginning_of_year</a>&nbsp;&nbsp;
      <a href="#M000575">change</a>&nbsp;&nbsp;
      <a href="#M000596">end_of_day</a>&nbsp;&nbsp;
      <a href="#M000599">end_of_month</a>&nbsp;&nbsp;
      <a href="#M000579">in</a>&nbsp;&nbsp;
      <a href="#M000586">last_month</a>&nbsp;&nbsp;
      <a href="#M000584">last_year</a>&nbsp;&nbsp;
      <a href="#M000593">midnight</a>&nbsp;&nbsp;
      <a href="#M000589">monday</a>&nbsp;&nbsp;
      <a href="#M000580">months_ago</a>&nbsp;&nbsp;
      <a href="#M000581">months_since</a>&nbsp;&nbsp;
      <a href="#M000587">next_month</a>&nbsp;&nbsp;
      <a href="#M000591">next_week</a>&nbsp;&nbsp;
      <a href="#M000585">next_year</a>&nbsp;&nbsp;
      <a href="#M000574">seconds_since_midnight</a>&nbsp;&nbsp;
      <a href="#M000578">since</a>&nbsp;&nbsp;
      <a href="#M000606">tomorrow</a>&nbsp;&nbsp;
      <a href="#M000582">years_ago</a>&nbsp;&nbsp;
      <a href="#M000583">years_since</a>&nbsp;&nbsp;
      <a href="#M000605">yesterday</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">

    <div id="class-list">
      <h3 class="section-bar">Classes and Modules</h3>

      Module <a href="Calculations/ClassMethods.html" class="link">ActiveSupport::CoreExtensions::Time::Calculations::ClassMethods</a><br />

    </div>




      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000576" class="method-detail">
        <a name="M000576"></a>

        <div class="method-heading">
          <a href="#M000576" class="method-signature">
          <span class="method-name">advance</span><span class="method-args">(options)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Uses Date to provide precise Time calculations for years, months, and days.
The <tt>options</tt> parameter takes a hash with any of these keys: :years,
:months, :weeks, :days, :hours, :minutes, :seconds.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000576-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000576-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 76</span>
76:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">advance</span>(<span class="ruby-identifier">options</span>)
77:           <span class="ruby-identifier">d</span> = <span class="ruby-identifier">to_date</span>.<span class="ruby-identifier">advance</span>(<span class="ruby-identifier">options</span>)
78:           <span class="ruby-identifier">time_advanced_by_date</span> = <span class="ruby-identifier">change</span>(<span class="ruby-identifier">:year</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">d</span>.<span class="ruby-identifier">year</span>, <span class="ruby-identifier">:month</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">d</span>.<span class="ruby-identifier">month</span>, <span class="ruby-identifier">:day</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">d</span>.<span class="ruby-identifier">day</span>)
79:           <span class="ruby-identifier">seconds_to_advance</span> = (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:seconds</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>) <span class="ruby-operator">+</span> (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:minutes</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>) <span class="ruby-operator">*</span> <span class="ruby-value">60</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:hours</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>) <span class="ruby-operator">*</span> <span class="ruby-value">3600</span>
80:           <span class="ruby-identifier">seconds_to_advance</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">time_advanced_by_date</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">time_advanced_by_date</span>.<span class="ruby-identifier">since</span>(<span class="ruby-identifier">seconds_to_advance</span>)
81:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000577" class="method-detail">
        <a name="M000577"></a>

        <div class="method-heading">
          <a href="#M000577" class="method-signature">
          <span class="method-name">ago</span><span class="method-args">(seconds)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the time a number of seconds <a
href="Calculations.html#M000577">ago</a>, this is basically a wrapper
around the Numeric extension Do not use this method <a
href="Calculations.html#M000579">in</a> combination with x.months, use <a
href="Calculations.html#M000580">months_ago</a> instead!
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000577-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000577-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 85</span>
85:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ago</span>(<span class="ruby-identifier">seconds</span>)
86:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">since</span>(<span class="ruby-operator">-</span><span class="ruby-identifier">seconds</span>)
87:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000595" class="method-detail">
        <a name="M000595"></a>

        <div class="method-heading">
          <span class="method-name">at_beginning_of_day</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000592">beginning_of_day</a>
</p>
        </div>
      </div>

      <div id="method-M000598" class="method-detail">
        <a name="M000598"></a>

        <div class="method-heading">
          <span class="method-name">at_beginning_of_month</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000597">beginning_of_month</a>
</p>
        </div>
      </div>

      <div id="method-M000602" class="method-detail">
        <a name="M000602"></a>

        <div class="method-heading">
          <span class="method-name">at_beginning_of_quarter</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000601">beginning_of_quarter</a>
</p>
        </div>
      </div>

      <div id="method-M000590" class="method-detail">
        <a name="M000590"></a>

        <div class="method-heading">
          <span class="method-name">at_beginning_of_week</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000588">beginning_of_week</a>
</p>
        </div>
      </div>

      <div id="method-M000604" class="method-detail">
        <a name="M000604"></a>

        <div class="method-heading">
          <span class="method-name">at_beginning_of_year</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000603">beginning_of_year</a>
</p>
        </div>
      </div>

      <div id="method-M000600" class="method-detail">
        <a name="M000600"></a>

        <div class="method-heading">
          <span class="method-name">at_end_of_month</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000599">end_of_month</a>
</p>
        </div>
      </div>

      <div id="method-M000594" class="method-detail">
        <a name="M000594"></a>

        <div class="method-heading">
          <span class="method-name">at_midnight</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000592">beginning_of_day</a>
</p>
        </div>
      </div>

      <div id="method-M000592" class="method-detail">
        <a name="M000592"></a>

        <div class="method-heading">
          <a href="#M000592" class="method-signature">
          <span class="method-name">beginning_of_day</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the start of the day (0:00)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000592-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000592-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 157</span>
157:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginning_of_day</span>
158:           (<span class="ruby-keyword kw">self</span> <span class="ruby-operator">-</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">seconds_since_midnight</span>).<span class="ruby-identifier">change</span>(<span class="ruby-identifier">:usec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>)
159:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000597" class="method-detail">
        <a name="M000597"></a>

        <div class="method-heading">
          <a href="#M000597" class="method-signature">
          <span class="method-name">beginning_of_month</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the start of the month (1st of the month,
0:00)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000597-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000597-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 170</span>
170:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginning_of_month</span>
171:           <span class="ruby-comment cmt">#self - ((self.mday-1).days + self.seconds_since_midnight)</span>
172:           <span class="ruby-identifier">change</span>(<span class="ruby-identifier">:day</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>,<span class="ruby-identifier">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:min</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:sec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:usec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>)
173:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000601" class="method-detail">
        <a name="M000601"></a>

        <div class="method-heading">
          <a href="#M000601" class="method-signature">
          <span class="method-name">beginning_of_quarter</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the start of the quarter (1st of january,
april, july, october, 0:00)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000601-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000601-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 185</span>
185:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginning_of_quarter</span>
186:           <span class="ruby-identifier">beginning_of_month</span>.<span class="ruby-identifier">change</span>(<span class="ruby-identifier">:month</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value">10</span>, <span class="ruby-value">7</span>, <span class="ruby-value">4</span>, <span class="ruby-value">1</span>].<span class="ruby-identifier">detect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">m</span><span class="ruby-operator">|</span> <span class="ruby-identifier">m</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">month</span> })
187:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000588" class="method-detail">
        <a name="M000588"></a>

        <div class="method-heading">
          <a href="#M000588" class="method-signature">
          <span class="method-name">beginning_of_week</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the &quot;start&quot; of this week (Monday,
0:00)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000588-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000588-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 143</span>
143:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginning_of_week</span>
144:           <span class="ruby-identifier">days_to_monday</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">wday!</span>=<span class="ruby-value">0</span> <span class="ruby-operator">?</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">wday</span><span class="ruby-operator">-</span><span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">6</span>
145:           (<span class="ruby-keyword kw">self</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">days_to_monday</span>.<span class="ruby-identifier">days</span>).<span class="ruby-identifier">midnight</span>
146:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000603" class="method-detail">
        <a name="M000603"></a>

        <div class="method-heading">
          <a href="#M000603" class="method-signature">
          <span class="method-name">beginning_of_year</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the start of the year (1st of january,
0:00)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000603-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000603-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 191</span>
191:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">beginning_of_year</span>
192:           <span class="ruby-identifier">change</span>(<span class="ruby-identifier">:month</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>,<span class="ruby-identifier">:day</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>,<span class="ruby-identifier">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:min</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:sec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:usec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>)
193:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000575" class="method-detail">
        <a name="M000575"></a>

        <div class="method-heading">
          <a href="#M000575" class="method-signature">
          <span class="method-name">change</span><span class="method-args">(options)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time where one or more of the elements have been changed
according to the <tt>options</tt> parameter. The time options (hour,
minute, sec, usec) reset cascadingly, so if only the hour is passed, then
minute, sec, and usec is set to 0. If the hour and minute is passed, then
sec and usec is set to 0.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000575-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000575-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 61</span>
61:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">change</span>(<span class="ruby-identifier">options</span>)
62:           <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">send</span>(
63:             <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">utc?</span> <span class="ruby-value">? </span><span class="ruby-operator">:</span><span class="ruby-identifier">utc_time</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">:local_time</span>,
64:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:year</span>]  <span class="ruby-operator">||</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">year</span>,
65:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:month</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">month</span>,
66:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:day</span>]   <span class="ruby-operator">||</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">day</span>,
67:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:hour</span>]  <span class="ruby-operator">||</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">hour</span>,
68:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:min</span>]   <span class="ruby-operator">||</span> (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:hour</span>] <span class="ruby-operator">?</span> <span class="ruby-value">0</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">min</span>),
69:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:sec</span>]   <span class="ruby-operator">||</span> ((<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:hour</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:min</span>]) <span class="ruby-operator">?</span> <span class="ruby-value">0</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">sec</span>),
70:             <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:usec</span>]  <span class="ruby-operator">||</span> ((<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:hour</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:min</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:sec</span>]) <span class="ruby-operator">?</span> <span class="ruby-value">0</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">usec</span>)
71:           )
72:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000596" class="method-detail">
        <a name="M000596"></a>

        <div class="method-heading">
          <a href="#M000596" class="method-signature">
          <span class="method-name">end_of_day</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the end of the day (23:59:59)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000596-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000596-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 165</span>
165:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">end_of_day</span>
166:           <span class="ruby-identifier">change</span>(<span class="ruby-identifier">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">23</span>, <span class="ruby-identifier">:min</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">59</span>, <span class="ruby-identifier">:sec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">59</span>)
167:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000599" class="method-detail">
        <a name="M000599"></a>

        <div class="method-heading">
          <a href="#M000599" class="method-signature">
          <span class="method-name">end_of_month</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the end of the month (last day of the
month, 0:00)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000599-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000599-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 177</span>
177:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">end_of_month</span>
178:           <span class="ruby-comment cmt">#self - ((self.mday-1).days + self.seconds_since_midnight)</span>
179:           <span class="ruby-identifier">last_day</span> = <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">days_in_month</span>( <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">month</span>, <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">year</span> )
180:           <span class="ruby-identifier">change</span>(<span class="ruby-identifier">:day</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">last_day</span>, <span class="ruby-identifier">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">23</span>, <span class="ruby-identifier">:min</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">59</span>, <span class="ruby-identifier">:sec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">59</span>, <span class="ruby-identifier">:usec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>)
181:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000579" class="method-detail">
        <a name="M000579"></a>

        <div class="method-heading">
          <span class="method-name">in</span><span class="method-args">(seconds)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000578">since</a>
</p>
        </div>
      </div>

      <div id="method-M000586" class="method-detail">
        <a name="M000586"></a>

        <div class="method-heading">
          <a href="#M000586" class="method-signature">
          <span class="method-name">last_month</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Short-hand for <a href="Calculations.html#M000580">months_ago</a>(1)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000586-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000586-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 133</span>
133:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">last_month</span>
134:           <span class="ruby-identifier">months_ago</span>(<span class="ruby-value">1</span>)
135:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000584" class="method-detail">
        <a name="M000584"></a>

        <div class="method-heading">
          <a href="#M000584" class="method-signature">
          <span class="method-name">last_year</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Short-hand for <a href="Calculations.html#M000582">years_ago</a>(1)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000584-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000584-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 122</span>
122:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">last_year</span>
123:           <span class="ruby-identifier">years_ago</span>(<span class="ruby-value">1</span>)
124:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000593" class="method-detail">
        <a name="M000593"></a>

        <div class="method-heading">
          <span class="method-name">midnight</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000592">beginning_of_day</a>
</p>
        </div>
      </div>

      <div id="method-M000589" class="method-detail">
        <a name="M000589"></a>

        <div class="method-heading">
          <span class="method-name">monday</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Calculations.html#M000588">beginning_of_week</a>
</p>
        </div>
      </div>

      <div id="method-M000580" class="method-detail">
        <a name="M000580"></a>

        <div class="method-heading">
          <a href="#M000580" class="method-signature">
          <span class="method-name">months_ago</span><span class="method-args">(months)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the time a number of specified months <a
href="Calculations.html#M000577">ago</a>
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000580-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000580-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 102</span>
102:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">months_ago</span>(<span class="ruby-identifier">months</span>)
103:           <span class="ruby-identifier">advance</span>(<span class="ruby-identifier">:months</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-operator">-</span><span class="ruby-identifier">months</span>)
104:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000581" class="method-detail">
        <a name="M000581"></a>

        <div class="method-heading">
          <a href="#M000581" class="method-signature">
          <span class="method-name">months_since</span><span class="method-args">(months)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the time a number of specified months <a
href="Calculations.html#M000579">in</a> the future
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000581-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000581-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 107</span>
107:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">months_since</span>(<span class="ruby-identifier">months</span>)
108:           <span class="ruby-identifier">advance</span>(<span class="ruby-identifier">:months</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">months</span>)
109:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000587" class="method-detail">
        <a name="M000587"></a>

        <div class="method-heading">
          <a href="#M000587" class="method-signature">
          <span class="method-name">next_month</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Short-hand for <a href="Calculations.html#M000581">months_since</a>(1)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000587-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000587-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 138</span>
138:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">next_month</span>
139:           <span class="ruby-identifier">months_since</span>(<span class="ruby-value">1</span>)
140:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000591" class="method-detail">
        <a name="M000591"></a>

        <div class="method-heading">
          <a href="#M000591" class="method-signature">
          <span class="method-name">next_week</span><span class="method-args">(day = :monday)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the start of the given day <a
href="Calculations.html#M000579">in</a> next week (default is Monday).
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000591-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000591-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 151</span>
151:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">next_week</span>(<span class="ruby-identifier">day</span> = <span class="ruby-identifier">:monday</span>)
152:           <span class="ruby-identifier">days_into_week</span> = { <span class="ruby-identifier">:monday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:tuesday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>, <span class="ruby-identifier">:wednesday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">2</span>, <span class="ruby-identifier">:thursday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">3</span>, <span class="ruby-identifier">:friday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">4</span>, <span class="ruby-identifier">:saturday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">5</span>, <span class="ruby-identifier">:sunday</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">6</span>}
153:           <span class="ruby-identifier">since</span>(<span class="ruby-value">1</span>.<span class="ruby-identifier">week</span>).<span class="ruby-identifier">beginning_of_week</span>.<span class="ruby-identifier">since</span>(<span class="ruby-identifier">days_into_week</span>[<span class="ruby-identifier">day</span>].<span class="ruby-identifier">day</span>).<span class="ruby-identifier">change</span>(<span class="ruby-identifier">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>)
154:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000585" class="method-detail">
        <a name="M000585"></a>

        <div class="method-heading">
          <a href="#M000585" class="method-signature">
          <span class="method-name">next_year</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Short-hand for <a href="Calculations.html#M000583">years_since</a>(1)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000585-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000585-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 127</span>
127:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">next_year</span>
128:           <span class="ruby-identifier">years_since</span>(<span class="ruby-value">1</span>)
129:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000574" class="method-detail">
        <a name="M000574"></a>

        <div class="method-heading">
          <a href="#M000574" class="method-signature">
          <span class="method-name">seconds_since_midnight</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Seconds <a href="Calculations.html#M000578">since</a> <a
href="Calculations.html#M000593">midnight</a>: Time.now.<a
href="Calculations.html#M000574">seconds_since_midnight</a>
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000574-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000574-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 54</span>
54:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">seconds_since_midnight</span>
55:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">-</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">change</span>(<span class="ruby-identifier">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>).<span class="ruby-identifier">to_i</span> <span class="ruby-operator">+</span> (<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">usec</span><span class="ruby-operator">/</span><span class="ruby-value">1.0e+6</span>)
56:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000578" class="method-detail">
        <a name="M000578"></a>

        <div class="method-heading">
          <a href="#M000578" class="method-signature">
          <span class="method-name">since</span><span class="method-args">(seconds)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the time a number of seconds <a
href="Calculations.html#M000578">since</a> the instance time, this is
basically a wrapper around the Numeric extension. Do not use this method <a
href="Calculations.html#M000579">in</a> combination with x.months, use <a
href="Calculations.html#M000581">months_since</a> instead!
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000578-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000578-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 91</span>
91:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">since</span>(<span class="ruby-identifier">seconds</span>)
92:           <span class="ruby-identifier">initial_dst</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">dst?</span> <span class="ruby-value">? </span><span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>
93:           <span class="ruby-identifier">f</span> = <span class="ruby-identifier">seconds</span>.<span class="ruby-identifier">since</span>(<span class="ruby-keyword kw">self</span>)
94:           <span class="ruby-identifier">final_dst</span>   = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">dst?</span> <span class="ruby-value">? </span><span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">0</span>
95:           (<span class="ruby-identifier">seconds</span>.<span class="ruby-identifier">abs</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">86400</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">initial_dst</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">final_dst</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">f</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">initial_dst</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">final_dst</span>).<span class="ruby-identifier">hours</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">f</span>
96:         <span class="ruby-keyword kw">rescue</span>
97:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_datetime</span>.<span class="ruby-identifier">since</span>(<span class="ruby-identifier">seconds</span>)          
98:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000606" class="method-detail">
        <a name="M000606"></a>

        <div class="method-heading">
          <a href="#M000606" class="method-signature">
          <span class="method-name">tomorrow</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Convenience method which returns a new Time representing the time 1 day <a
href="Calculations.html#M000578">since</a> the instance time
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000606-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000606-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 202</span>
202:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tomorrow</span>
203:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">since</span>(<span class="ruby-value">1</span>.<span class="ruby-identifier">day</span>)
204:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000582" class="method-detail">
        <a name="M000582"></a>

        <div class="method-heading">
          <a href="#M000582" class="method-signature">
          <span class="method-name">years_ago</span><span class="method-args">(years)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the time a number of specified years <a
href="Calculations.html#M000577">ago</a>
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000582-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000582-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 112</span>
112:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">years_ago</span>(<span class="ruby-identifier">years</span>)
113:           <span class="ruby-identifier">advance</span>(<span class="ruby-identifier">:years</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-operator">-</span><span class="ruby-identifier">years</span>)
114:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000583" class="method-detail">
        <a name="M000583"></a>

        <div class="method-heading">
          <a href="#M000583" class="method-signature">
          <span class="method-name">years_since</span><span class="method-args">(years)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new Time representing the time a number of specified years <a
href="Calculations.html#M000579">in</a> the future
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000583-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000583-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 117</span>
117:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">years_since</span>(<span class="ruby-identifier">years</span>)
118:           <span class="ruby-identifier">advance</span>(<span class="ruby-identifier">:years</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">years</span>)
119:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000605" class="method-detail">
        <a name="M000605"></a>

        <div class="method-heading">
          <a href="#M000605" class="method-signature">
          <span class="method-name">yesterday</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Convenience method which returns a new Time representing the time 1 day <a
href="Calculations.html#M000577">ago</a>
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000605-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000605-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 197</span>
197:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">yesterday</span>
198:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">ago</span>(<span class="ruby-value">1</span>.<span class="ruby-identifier">day</span>)
199:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>